<template>
  <div>
    <el-badge :value="num" class="item" type="primary">
      <i @click="handleClick" class="el-icon-message"></i>
    </el-badge>
  </div>
</template>

<script>
import {unraedCount} from '@/api/system/feedback/index'

export default {
  name: 'feedbackMessage',
  data() {
    return {
      num: this.$store.getters.num
    }
  },
  mounted() {
    this.getUnreadCount()
    this.$bus.$on('handleEmit', () => {
      // console.log(1)
      this.getUnreadCount()
    })
  },
  methods: {
    handleClick() {
      this.$router.push("/feedback-manage")
    },
    getUnreadCount() {
      unraedCount().then(res => {
        this.$store.commit('SET_NUM', res.data.count)
        this.num = res.data.count
      })
    },

    //


  },
  watch: {
    '$route': {
      immediate: true,
      handler() {
        this.getUnreadCount()
      }
    },
  }
}
</script>

<style>
.el-badge__content.is-fixed {
  top: 9px;
  right: 10px;
}
</style>
